﻿#region 命名空间

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Sharp.Domain.PlatformBoundedContext.PermissionModule.Aggregates;
using Sharp.Domain.Model;
using Sharp.Infrastructure;
using Sharp.Domain.PlatformBoundedContext.OrgModule.Aggregates;

#endregion

namespace Sharp.Domain.PlatformBoundedContext.UserModule.Aggregates
{
    /// <summary>
    ///     角色
    /// </summary>
    public partial class Role : IAggregateRoot<int>, ILogCreatedEntity, ILogModifiEntity, IStandardState
    {
        #region 构造函数

        /// <summary>
        ///     初始化一个新的<c>Role</c>实例。
        /// </summary>
        public Role()
        {
            Users = new List<User>();
            Permissions = new List<Permission>();
        }

        /// <summary>
        ///     初始化一个新的<c>Role</c>实例。
        /// </summary>
        /// <param name="name">角色名称。</param>
        /// <param name="description">角色描述。</param>
        public Role(string name, string description)
        {
            Name = name;
            Remark = description;
        }

        #endregion

        [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }
        /// <summary>
        /// 获取或设置角色描述
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 编码
        /// </summary>
        public string Code { get; set; }
        /// <summary>
        /// 组织id
        /// </summary>
        public System.Guid? OrgId { get; set; }
        /// <summary>
        /// 获取或设置角色描述
        /// </summary>
        public string Remark { get; set; }
        /// <summary>
        /// 角色里的用户
        /// </summary>
        public virtual ICollection<User> Users { get; set; }

        /// <summary>
        /// 权限
        /// </summary>
        /// <param name="?"></param>
        public virtual ICollection<Permission> Permissions { get; set; }
        /// <summary>
        /// 添加日期
        /// </summary>
        public System.DateTime? CreatedTime { get; set; }
        /// <summary>
        /// 录入员的id
        /// </summary>
        public int? CreatedUserId { get; set; }
        /// <summary>
        /// 修改时间
        /// </summary>
        public System.DateTime? ModifiTime { get; set; }
        /// <summary>
        /// 修改数据的用户Id
        /// </summary>
        public int? ModifiedUserId { get; set; }

        public EntityStateOperate EntityState
        {
            get;
            set;
        }
        /// <summary>
        /// 所属组织
        /// </summary>
        [ForeignKey("OrgId")]
        public virtual Org Org { get; set; }

        /// <summary>
        /// 已授权组织
        /// </summary>
        public virtual ICollection<Org> AuthorizedOrgs { get; set; }
    }
}